\section{Implementation}

\begin{frame}{Implementation}
\begin{center}
\begin{figure}[h!]
\centering
\resizebox{0.6\linewidth}{!}{
	\begin{tikzpicture}[>=stealth',shorten >=1pt,auto, semithick]
	\tikzstyle{every state}=[rectangle,minimum height=1.0cm, minimum width=3cm, node distance=1.5cm,align=center,font=\footnotesize]

		\node[state, minimum width=6.8cm]  (16) {WLAN};
		\node[state, draw=white, left of=16, xshift=-0.4cm]  (16l) {};
		\node[state, draw=white, right of=16, xshift=0.4cm]  (16r) {};
		\node[state, minimum width=6.8cm]  (16) {WLAN};
		
		\node[state, left of=16, above of=16, xshift=-0.4cm]  (15) {Network interface};
		\node[state, above of=15] (14)  {Network coding};
		\node[state, above of=14] (13) {Serialiser};
		\node[state, above of=13] (12) {FFmpeg};
		\node[state, above of=12] (11) {Display (Qt)};
		\node[state, above of=11, draw=none, yshift=-.5cm] (server) {Server};
		\node[state, left of=12,node distance=3.75cm] (10) {Video data};

		\draw[dashed,draw=black!30,-] ([xshift=0.25cm, yshift=0.25cm]11.north east) -| ([xshift=-0.25cm, yshift=-0.25cm]15.south west) -| ([xshift=0.25cm, yshift=0.25cm]11.north east);

		\path	(10)	edge[->] node {}	(12);									
		\path	(12)	edge[->] node {}	(11);
		\path	(12)  edge[->] node {}	(13);
		\path	(13)	edge[->] node {}	(14);
		\path	(14)	edge[->] node {} (15);
		\path	(15)	edge[->] node {} (16l);

		\node[state, right of=16, above of=16, xshift=0.4cm]  (25) {Network interface};
		\node[state, above of=25] (24)  {Network coding};
		\node[state, above of=24] (23) {Deserialiser};
		\node[state, above of=23] (22) {FFmpeg};		
		\node[state, above of=22] (21) {Display (Qt)};
		\node[state, above of=21, xshift=0.5cm, draw=none] (nodes) {Nodes};

		\draw[dashed,draw=black!30,-] ([xshift=-0.25cm, yshift=0.25cm]21.north west) -| ([xshift=0.25cm, yshift=-0.25cm]25.south east) -| ([xshift=-0.25cm, yshift=0.25cm]21.north west);
		\draw[dashed,draw=black!30,-] ([xshift=0cm, yshift=0.25cm]21.north west) -- ([xshift=0cm, yshift=0.5cm]21.north west) -| ([xshift=0.5cm, yshift=0cm]25.south east) -- ([xshift=0.25cm, yshift=0cm]25.south east);
		\draw[dashed,draw=black!30,-] ([xshift=0.25cm, yshift=0.5cm]21.north west) -- ([xshift=0.25cm, yshift=0.75cm]21.north west) -| ([xshift=0.75cm, yshift=0.25cm]25.south east) -- ([xshift=0.5cm, yshift=0.25cm]25.south east);

		\path	(22)  edge[->] node {}	(21);
		\path	(23)	edge[->] node {}	(22);
		\path	(24)	edge[->] node {} (23);
		\path	(25)	edge[->] node {} (24);
		\path	(16r)	edge[->] node {}	(25);
	\end{tikzpicture}}
\caption{4.1, Page 55}
\label{dummy}
\end{figure}
\end{center}
\end{frame}

\begin{frame}{Implementation}
\begin{center}
\begin{figure}[h!]
\centering
\resizebox{0.6\linewidth}{!}{
	\begin{tikzpicture}[>=stealth',shorten >=1pt,auto, semithick]
	\tikzstyle{every state}=[rectangle,minimum height=1.0cm, minimum width=3cm, node distance=1.5cm,align=center,font=\footnotesize]

		\node[state, minimum width=6.8cm]  (16) {WLAN};
		\node[state, draw=white, left of=16, xshift=-0.4cm]  (16l) {};
		\node[state, draw=white, right of=16, xshift=0.4cm]  (16r) {};
		\node[state, minimum width=6.8cm]  (16) {WLAN};
		
		\node[state, left of=16, above of=16, xshift=-0.4cm]  (15) {Network interface};
		\node[state, above of=15] (14)  {Network coding};
		\node[state, above of=14] (13) {Serialiser};
		\node[state, above of=13] (12) {FFmpeg};
		\node[state, above of=12] (11) {Display (Qt)};
		\node[state, above of=11, draw=none, yshift=-.5cm] (server) {Server};
		\node[state, left of=12,node distance=3.75cm] (10) {Video data};

		\draw[dashed,draw=black!30,-] ([xshift=0.25cm, yshift=0.25cm]11.north east) -| ([xshift=-0.25cm, yshift=-0.25cm]15.south west) -| ([xshift=0.25cm, yshift=0.25cm]11.north east);

		\path	(10)	edge[->] node {}	(12);									
		\path	(12)	edge[->] node {}	(11);
		\path	(12)  edge[->] node {}	(13);
		\path	(13)	edge[->] node {}	(14);
		\path	(14)	edge[->] node {} (15);
		\path	(15)	edge[->] node {} (16l);

		\node[state, right of=16, above of=16, xshift=0.4cm]  (25) {Network interface};
		\node[state, above of=25] (24)  {Network coding};
		\node[state, above of=24] (23) {Deserialiser};
		\node[state, above of=23] (22) {FFmpeg};		
		\node[state, above of=22] (21) {Display (Qt)};
		\node[state, above of=21, xshift=0.5cm, draw=none] (nodes) {Nodes};

		\draw[dashed,draw=black!30,-] ([xshift=-0.25cm, yshift=0.25cm]21.north west) -| ([xshift=0.25cm, yshift=-0.25cm]25.south east) -| ([xshift=-0.25cm, yshift=0.25cm]21.north west);
		\draw[dashed,draw=black!30,-] ([xshift=0cm, yshift=0.25cm]21.north west) -- ([xshift=0cm, yshift=0.5cm]21.north west) -| ([xshift=0.5cm, yshift=0cm]25.south east) -- ([xshift=0.25cm, yshift=0cm]25.south east);
		\draw[dashed,draw=black!30,-] ([xshift=0.25cm, yshift=0.5cm]21.north west) -- ([xshift=0.25cm, yshift=0.75cm]21.north west) -| ([xshift=0.75cm, yshift=0.25cm]25.south east) -- ([xshift=0.5cm, yshift=0.25cm]25.south east);

		\path	(22)  edge[->] node {}	(21);
		\path	(23)	edge[->] node {}	(22);
		\path	(24)	edge[->] node {} (23);
		\path	(25)	edge[->] node {} (24);
		\path	(16r)	edge[->] node {}	(25);
		
		\node[circle, draw=red, below of=25,node distance=0.75cm]  (v1) {};
		\node[circle, draw=red, below of=24,node distance=0.75cm]  (v2) {};
	\end{tikzpicture}}
\caption{4.1, Page 55}
\label{dummy}
\end{figure}
\end{center}
\end{frame}

\begin{frame}{Receive symbols}
\begin{center}
\begin{figure}[h!]
\centering
\resizebox{0.9\linewidth}{!}{
	\begin{tikzpicture}[>=stealth',shorten >=1pt,auto, semithick]
	\tikzstyle{every state}=[fill=white,text=black, minimum height=0.5cm, minimum width=2.2cm, node distance=2.6cm, font=\tiny,align=center]

		\node[state, rectangle, minimum width=.01cm,draw=white,minimum height=0.6cm] (start){};
		\node[state, left of=start, node distance=0cm, rectangle, minimum width=10cm] (sharedmem){};
		\node[left of=start,node distance=3cm,font=\footnotesize,align=left]{Shared memory timeline};
		\node[state, rectangle, dashed, right of=start, node distance=0.75cm, minimum width=2cm](L1){Locked};
		\node[state, rectangle, dashed, right of=L1, node distance=2.5cm,minimum width=2cm](L2){Locked};
		%%Receive thread 
		
		\node[state,draw,diamond,minimum width=2cm,above of=sharedmem,xshift=-5.5cm,yshift=.3cm] (newp) {New\\packet\\detected?};
		\node[below of=newp,node distance=2cm]{Receive thread};	
		\node[state, rectangle, right of=newp,node distance=3.5cm](save) {Save new packet\\in shared memory\\ while protected};
		
		\draw[->] (newp) -- node[above,font=\tiny]{yes} (save);
		
		\draw[->,dashed] (save.south west) -- (L1.north west);
		\draw[->,dashed] (L1.north east) -- (save.south east);
		
		\draw[->] (save.east) -| ([xshift=.5cm,yshift=1.25cm]save.north east) -| (newp.north);
		\draw[->]  (newp.south) |- node[above,font=\tiny,xshift=0.25cm]{no} ([xshift=-1.7cm,yshift=-0.3cm]newp.south) |- (newp.west);
		
		%%Fetch packet thread
		\node[state,draw,diamond,minimum width=2cm,below of=sharedmem,xshift=-5.5cm,,yshift=-.3cm] (getnewp) {New packet\\needed for\\decoders?};
		\node[above of=getnewp,node distance=2cm] {Get packet thread};	
		\node[state, rectangle, right of=getnewp,node distance=3cm] (get) {Get new\\packet from\\shared memory};
		\node[state, rectangle, right of=get] (remove) {Remove\\header\\from packet};
		\node[state, rectangle, right of=remove] (zeropad) {Zero pad\\ packet to fit\\ all decoders};
		\node[state, rectangle, right of=zeropad, fill=black!30,minimum height=	1cm] (end) {New layer\\n packet};
		
		\draw[->] (getnewp) -- node[above,font=\tiny]{yes}  (get);
		\draw[->] (get) -- (remove);
		\draw[->] (remove) -- (zeropad);
		\draw[->] (zeropad) -- (end);
		
		\draw[->,dashed] (get.north west) -- (L2.south west);
		\draw[->,dashed] (L2.south east) -- (get.north east);
		
		\draw[->] (end.south) --  node[midway,font=\tiny] {Continue} ([yshift=-1.25cm]end.south) -| (getnewp.south);
		\draw[->]  (getnewp.north) |- node[below,font=\tiny,xshift=0.25cm]{no} ([xshift=-1.7cm,yshift=0.3cm]getnewp.north) |- (getnewp.west);
	\end{tikzpicture}}
\caption{4.5, Page 58}
\label{dummy}
\end{figure}
\end{center}
\end{frame}

\begin{frame}{Distribute symbols}
\begin{center}
\begin{figure}[h!]
\centering
\resizebox{1.0\linewidth}{!}{
	\begin{tikzpicture}[>=stealth',shorten >=1pt,auto, semithick]
	\tikzstyle{every state}=[fill=white,text=black, minimum height=0.5cm, minimum width=2cm, node distance=2.8cm, font=\tiny,align=center]
		
		\node[state, rectangle, fill=black!30](new) {New layer\\n packet};
		
		\node[state,draw,diamond,minimum width=2cm,right of=new](newgen) {New\\generation\\detected?};
		
		\node[state, rectangle,below of=newgen,node distance=2.5cm](return) {Return decoded data\\from highest\\layer possible from\\old generation\\ and clear buffers};
		
		\node[state, rectangle,right of=newgen,node distance=2.5cm](store) {Store new \\packet in as\\many buffers\\as there\\are layers};
		
		\node[state,draw,diamond,right of=store,node distance=2.5cm](newlayer) {New\\layer\\detected?};
		
		\node[state, rectangle,right of=newgen,node distance=2.5cm](store) {Store new \\packet in as\\many buffers\\as there\\is layers};

		\node[state, rectangle,right of=newlayer,node distance=2.5cm](distributor) {Packet\\distributor};
		
		\node[state, rectangle,below of=newlayer,node distance=2cm](create) {Create decoder\\for new layer};
		
		\node[state, rectangle,right of=distributor,node distance=2.5cm](D2) {Decoder $n$};
		\node[state, rectangle,above of=D2,node distance=1cm](D1) {Decoders $>n$};
		\node[state, rectangle, dashed,below of=D2,node distance=1cm](D3) {Decoder $n-1$};
				
		\path[->] (new) edge (newgen);
		\path[->] (newgen) edge node[left,font=\tiny]{yes} (return);
		\draw[->] (return) -| (store);
		\path[->] (newgen) edge node[above,font=\tiny,xshift=-0.1cm]{no} (store);
		\path[->] (store) edge (newlayer);
		\path[->] (newlayer) edge node[above,font=\tiny,xshift=-0.1cm]{no} (distributor);
		\path[->] (newlayer) edge node[left,font=\tiny]{yes} (create) ;
		\draw[->] (create) -| (distributor);
		\draw[->] (distributor) -- (D1.west);
		\draw[->] (distributor) -- (D2);
	\end{tikzpicture}}
\caption{4.6, Page 58}
\label{dummy}
\end{figure}
\end{center}
\end{frame}